Handlebars.registerHelper('selectType', function(v1, options){
   var type = {6:'',7:'',8:'',9:'',11:'',12:'',13:'',10:''};
   v1 ? v1 : v1 = 8 ;
   type[v1] = 'selected';
   return '<option '+type[6]+'  value="6">标签</option><option '+type[7]+'  value="7">背景</option><option '+type[8]+' value="8">贴纸</option><option  '+type[9]+' value="9">花边笔</option><option '+type[11]+'  value="11">边框</option><option '+type[12]+'  value="12">插件</option><option '+type[13]+' value="13">引导器</option><option '+type[10]+' value="10">模板</option>';
});

Handlebars.registerHelper('selectStatus', function(v1, options){
   var status = {0:'', 1:''};
   v1!==undefined ? v1 : v1 = 1;
   status[v1] = 'selected';
   return '<option '+status[0]+' value="0">上线</option><option '+status[1]+' value="1">下线</option>';
});

Handlebars.registerHelper('displayStatus', function(v1, options){
    if(v1 === '0'){
        return '<i class="ion-checkmark-round"></i>';
    }else
    if(v1 === '1'){
       return '<i class="ion-close-round"></i>';
    }
});

Handlebars.registerHelper('displayLabel', function(v1, options){
    if(v1 === '1'){
        return '<i class="ion-checkmark-round"></i>';
    }else
    if(v1 === '0'){
        return '<i class="ion-close-round"></i>';
    }
});

Handlebars.registerHelper('displaylabelSelect', function(v1, options){
    var label= {1:'', 2:''};
    if(v1 == '1'){
        label[2] = 'selected';
    }else{
        label[1] = 'selected';
    }
    return '<option '+label[2]+' value="1">上推荐</option><option '+label[1]+' value="0">下推荐</option>';
});

Handlebars.registerHelper('displayOsSelect', function(v1, options){
    var os= {0:'', 1:'',2:'',3:''};
    os[v1] = 'selected';
    return '<option '+os[0]+' value="0">全部</option><option '+os[1]+' value="1">IOS</option><option '+os[2]+' value="2">安卓</option><option '+os[3]+' value="3">IOS专业</option>';
});

Handlebars.registerHelper('displaykindSelect', function(v1, options){
    var kind = {0:'',1:'',2:''};
    kind[v1] = 'selected';
    return '<option value="0" '+kind[0]+'>全部</option><option value="1" '+kind[1]+'>图片</option><option value="2" '+kind[2]+'>记录</option>';
});

Handlebars.registerHelper('displayCategorySelect', function(v1,v2, options){
    v1?v1:v1=8;
    var res;
    var str ='';
    var selected='';
    res = getPlannerCategory(v1);
    for(var i in res){
       selected='';
       if(res[i]['cid'] == v2){
           selected = 'selected';
       }
       str+='<option '+selected+' value="'+res[i]['cid']+'">'+res[i]['name']+'</option>';
    }
    return str;
});

Handlebars.registerHelper('displayTag', function(v1, options){
    var type = {1:'',2:'',3:''};
    if(v1 == 'new'){
        type[2]='selected';
    }else if(v1 == 'hot'){
        type[3]='selected';
    }else{
        type[1]='selected';
    }
    return '<option value="" '+type[1]+'>无</option><option value="new" '+type[2]+'>最新</option><option value="hot" '+type['3']+'>最热</option>';
});

Handlebars.registerHelper('displayTime', function(v1, options){
    return new Date(parseInt(v1) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ');
});

function getPlannerCategory(type){
    var where = {'action':'getPlannerCategoryList','type':type};
    var res = {};
    $.ajax(
        {
            dataType:   "json",
            url     :   'admin.php?ac=admin&op=start&do=planner',
            type    :   "GET",
            data    :   where,
            async   :   false,
            success :   function(data)
            {
               res = data.result;
            }
        });
    return res;
}
